#ifndef slak_mesh_Material_h
#define slak_mesh_Material_h

#include <SDL_opengl.h>
#include "Mesh.h"

namespace slak {
	namespace mesh {
		struct Material {
			virtual void setState() = 0;
			virtual void resetState() = 0;
			virtual void render(PatchList patch_list);


			static void glOnOff(GLenum what, bool state) {
				if (state)
					::glEnable(what);
				else
					glDisable(what);
			}
		};


		struct OglMaterial : Material {
			float diffuse[4];
			float ambient[4];
			float specular[4];
			float shininess;
			GLenum polygon_mode;
			bool blend;
			
			virtual void setState();
			virtual void resetState();

			void setDiffuse(float r, float g, float b, float a=1)
			{	
				diffuse[0] = r; diffuse[1] = g;
				diffuse[2] = b; diffuse[3] = a; 
			}

			void setAmbient(float r, float g, float b, float a=1)
			{	
				ambient[0] = r; ambient[1] = g;
				ambient[2] = b; ambient[3] = a; 
			}

			void setSpecular(float r, float g, float b, float a=1)
			{	
				specular[0] = r; specular[1] = g;
				specular[2] = b; specular[3] = a; 
			}

		};

		struct MultipassMaterial : Material {
			MaterialList passes;
			virtual void setState() {}
			virtual void resetState() {}

			virtual void render(PatchList patch_list);
		};
	}
}

#endif

